home *** CD-ROM | disk | FTP | other *** search
- /**
- GRAB Graph Layout and Browser System
-
- Copyright (c) 1986, 1988 Regents of the University of California
- Copyright (c) 1989, Tera Computer Company
- **/
-
- /* routine to print neat program statistics */
-
- #include <sys/time.h>
- #include <sys/resource.h>
-
- void DoPrintUsage()
- {
- struct rusage ru;
- double ut, st, up, sp, tot;
-
- getrusage(RUSAGE_SELF, &ru);
-
- ut = (ru.ru_utime.tv_sec) + (ru.ru_utime.tv_usec / 1e06);
- st = (ru.ru_stime.tv_sec) + (ru.ru_stime.tv_usec / 1e06);
- tot = ut + st;
- up = (ut / tot) * 100.0;
- sp = (st / tot) * 100.0;
-
- printf("\nUser Time: %6.2f sec. (%5.1f%%)\n", ut, up);
- printf("System Time: %6.2f sec. (%5.1f%%)\n", st, sp);
- printf("Total Time: %6.2f sec. (%5.1f%%)\n", tot, up + sp);
-
- printf("Maximum resident set size: %d Kbytes\n", ru.ru_maxrss);
- printf("Shared memory size: %d Kbyte*seconds\n", ru.ru_ixrss);
- printf("Unshared data size: %d Kbytes*seconds\n", ru.ru_idrss);
- printf("Unshared stack size: %d Kbytes*seconds\n", ru.ru_isrss);
-
- printf("Page faults without io: %d\n", ru.ru_minflt);
- printf("Page faults with io: %d\n", ru.ru_majflt);
-
- printf("Number of times swapped: %d\n", ru.ru_nswap);
-
- printf("Number of file system inputs: %d\n", ru.ru_inblock);
- printf("Number of file system outputs: %d\n", ru.ru_oublock);
-
- printf("Number of ipc messages sent: %d\n", ru.ru_msgsnd);
- printf("Number of ipc messages received: %d\n", ru.ru_msgrcv);
-
- printf("Number of signals received: %d\n", ru.ru_nsignals);
-
- tot = ru.ru_nvcsw + ru.ru_nivcsw;
- up = (ru.ru_nvcsw / tot) * 100.0;
- sp = (ru.ru_nivcsw / tot) * 100.0;
-
- printf("Number of voluntary context switches: %4d (%5.1f%%)\n",
- ru.ru_nvcsw, up);
- printf("Number of involuntary context switches: %4d (%5.1f%%)\n",
- ru.ru_nivcsw, sp);
- printf("Total number of context switches: %4d (%5.1f%%)\n",
- (int) tot, up + sp);
- }
-